﻿/// <reference path="../../../Common/JQ/jquery-1.10.2.min.js" />
/// <reference path="../../../Common/EasyUI/jquery.easyui.min.js" />
/// <reference path="../../../Common/MyJS/MyRemoteCall.js" />
/// <reference path="../../../Common/MyJS/MyWebsite.js" />
/// <reference path="../../../Common/JQ/jquery.json-2.4.min.js" />

//文档加载完毕之后触发的事件
$(document).ready(function () {
    pageInitial();
    loadArchiveClass();
    openClass();
});

function pageInitial() {
    /// <summary>页面的初始化</summary>
    //实现布局
    $(document.body).layout();
    //配置图标按钮
    $($(document.body).layout('panel', 'west')).panel({
        tools: [{
            iconCls: 'icon-add',
            handler: function () {
                addClass();
            }
        }]
    });

    var iframe = '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" id="iframe_pageCenter" />'
    $($(document.body).layout('panel', 'center')).panel({
        content: iframe
    });
    $(document.body).layout();
};

function addClass() {
    /// <summary>添加一个分类</summary>

};

function openClass(id) {
    /// <summary>打开分类属性页面</summary>
    /// <param name="id" type="String">分类的id号</param>
    var sUrl = MyWebsite.getServerAddr() + "MISCommon/ArchiveSystem/ClassEdit.aspx";
    if (id) {
        sUrl = MyString.urlAppend(sUrl, "id=" + id);
    }
    $("#iframe_pageCenter").attr("src", sUrl);
};

function loadArchiveClass() {
    /// <summary>加载管理系统的分类</summary>
    $("#ul_archiveClass").tree({
        checkbox: true,
        data: getArchiveClass()
    });
};

function getArchiveClass() {
    /// <summary>获取管理系统的分类</summary>
    var sSystemID = MyWebsite.getQueryParam("id");
    var sTitle = MyWebsite.getQueryParam("title");
    var aArchiveClass = new Array();
    var sJSON = MyRemoteCall.execBLLFunctionSync("ArchiveSystemHelper.GetSystemAllClassEasyUIJSON", [sSystemID]);
    //附加上父节点
    var oParentNode = new Object();
    oParentNode.id = sSystemID;
    oParentNode.text = sTitle;
    oParentNode.state = "open";
    oParentNode.children = sJSON;
    return [oParentNode];
};
